def func(arr, x):
    l = 0
    r = len(arr)
    while l < r:
        n = (l + r) //2
        if arr[n] == x:
            return n
        elif arr[n]< x:
            l = n
        elif arr[n]> x:
            r = n
    return -1


if __name__ == '__main__':
    arr = [1, 2,3,4,5,6,8,9]
    n = func(arr, 2)
    print(n)